package com.r_z.controller;

import com.r_z.entity.UserRole;
import com.r_z.entity.Users;
import com.r_z.service.UserRoleService;
import com.r_z.service.UsersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author 梁俊
 * @date 2023/5/30
 * &@version 1.0
 */
@RestController
public class UserRoleController {

    @Autowired
    public UserRoleService userRoleService;



    @RequestMapping("/selectLikeUserRole")
    @CrossOrigin
    public Map selectLikeUserRole(String userRoleName, int page, int limit){
        if (userRoleName==null) {
            userRoleName="";
        }
        Map map=new HashMap();
        map.put("userRoleName","%"+userRoleName+"%");
        map.put("page",(page-1)*limit);
        map.put("limit",limit);
        List<UserRole> userRoles = userRoleService.selectLikeUserRole(map);
        int count = userRoleService.selectCountUserRole("%" + userRoleName + "%");
        Map map1=new HashMap();
        map1.put("code",0);
        map1.put("msg","");
        map1.put("count",count);
        map1.put("data",userRoles);
        return map1;
    }
}

